<template>
  <div class="container">
    <list-table-new v-bind="tableSetting" ref="listTable"></list-table-new>
  </div>
</template>

<script>
import { queryPageList } from "@/api/orderManagement/orderCommon";
export default {
  data(){
    return{
      tableSetting: {
        radioShow: true,
        showFilterBtn: false,
        showCustomBtn: false,
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getTableData(params, sortStr);
          },
          queryData: {
            page: 1,
            pageSize: 15,
            status: "WAIT_EXECUTE",
            orderTypeList: [
              "defect",
              "maintain",
              "overhaul",
              "experiment",
              "repair"
            ]
          },
          searchArr: [
            {
              type: "input",
              label: "编号",
              model: "code"
            },
            {
              type: "input",
              label: "标题",
              model: "title"
            },
            {
              type: "select",
              label: "工单类型",
              model: "orderTypeList",
              multiple: true,
              option:this.$store.getters.dirtData("order_change_type")
            },
            {
              type: "dept",
              label: "设备单位",
              model: "deptManageName",
              idsStr: "deptManage"
            },
            {
              type: "select",
              label: "专业",
              model: "major",
              option: this.$store.getters.dirtData("common_major")
            },
            {
              type: "dept",
              label: "作业单位",
              model: "deptWorkName",
              idsStr: "deptWork"
            }
          ]
        },
        column: [
          {
            label: "编号",
            prop: "code"
          },
          {
            label: "标题",
            prop: "title"
          },
          {
            label: "工单类型",
            prop: "orderType",
            formatter: row => {
              return this.$store.getters["fineDirtDataName"](
                "order_change_type",
                row.orderType
              );
            }
          },
          {
            label: "专业",
            prop: "major",
            formatter: row => {
              return this.$store.getters["fineDirtDataName"](
                "common_major",
                row.major
              );
            }
          },
          {
            label: "设备管理单位",
            prop: "deptManageName"
          },
          {
            label: "作业单位",
            prop: "deptWorkName"
          },
          {
            label: "计划开始时间",
            prop: "startTime"
          },
          {
            label: "计划结束时间",
            prop: "endTime"
          },
          {
            label: "工单来源",
            prop: "source",
            formatter: row => {
              return this.$store.getters["fineDirtDataName"](
                "order_source",
                row.source
              );
            }
          },
          {
            label: "状态",
            prop: "status",
            formatter: row => {
              return this.$store.getters["fineDirtDataName"](
                "order_all_status",
                row.status
              );
            }
          },
          {
            label: "创建人",
            prop: "createByName"
          },
          {
            label: "创建时间",
            prop: "createTime"
          }
        ],
        //表格方法
        tableMethods: {
          //点击行的方法
          rowClick: row => {
            this.$refs.listTable.radioSelect(row);
          }
        }
      },
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
        this.updateData();
    },
    updateData() {
      this.$refs.listTable.searchData();
    },
    getTableData(params, sortStr) {
      let queryData = Object.assign({}, params);
      if (sortStr.length > 0) {
        queryData.orders = sortStr;
      }
      queryPageList(queryData)
        .then(res => {
          let data = res.data.list || [];
          let total = res.data.total || 0;
          this.$set(this.tableSetting, "tableData", data);
          this.$set(this.tableSetting, "totalNumber", total);
        })
        .catch(e => {
          this.$set(this.tableSetting, "tableData", []);
          this.$set(this.tableSetting, "totalNumber", 0);
        });
    },
    //获取选择结果
    getSelectData() {
      let data = this.$refs.listTable.getRadioData();
      return data;
    }
  }
}
</script>
<style lang="less" scoped>
  .container {
    width: 100%;
    height: 100%;
    background-color: white;
    display: flex;
    text-align: center;
    .class-tree {
      height: 100%;
      width: 300px;
      border-top: 10px solid #f2f3f8;
    }
    .detail-content {
      height: 100%;
      width: calc(100% - 300px);
      border-left: 10px solid #f2f3f8;
      border-top: 10px solid #f2f3f8;
      padding: 20px;
      flex: 1;
      //overflow: auto;
    }
  }
</style>
